package com.weipai.education.controller;

import com.weipai.education.model.ActivityCate;
import com.weipai.education.model.UserCategory;
import com.weipai.education.model.api.Response;
import com.weipai.education.service.ActivityCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/11 09:55
 * 
 * 活动类别表
 */
@RestController
@Validated
public class ActivityCateController {

    @Autowired
    private ActivityCateService activityCateService;

    /**
     * 分页查询
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/activityCate/list", method = RequestMethod.GET)
    public Response list(@NotNull(message = "page不能为空") @RequestParam(value = "page") Integer page,
                         @NotNull(message = "size不能为空") @RequestParam(value = "size") Integer size){
        return activityCateService.list(page, size);
    }

    /**
     * 活动类别保存--修改
     * @param activityCate
     * @return
     */
    @RequestMapping(value = "/activityCate/save", method = RequestMethod.POST)
    public Response save(@Valid ActivityCate activityCate){
        return activityCateService.save(activityCate);
    }

    /**
     * 更改活动类别的状态
     * @param id
     * @return
     */
    @RequestMapping(value = "/activityCate/changeStatus", method = RequestMethod.GET)
    public Response changeStatus(@NotBlank(message = "id不能为空") String id){
        return activityCateService.changeStatus(id);
    }

    /**
     * 批量删除
     * @param id:
     * @return
     */
    @RequestMapping(value = "/activityCate/batchDeleteById", method = RequestMethod.GET)
    public Response batchDeleteById(@NotEmpty(message = "id不能为空") String[] id){
        return activityCateService.batchDeleteById(id);
    }
    
    
}
